package com.jilefojing.beans.enums.forexpose;

import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;


/**
 * 
 * @author 作者 jgshun
 * @date   创建时间 2016年07月24日 22时00分27秒
 */
public enum StatusEnumForExpose {
		/**
		 * (short) 1, "待处理"
		 */
		 	PENDING_TREATMENT((short) 1, "待处理"),
		/**
		 * (short) 2, "已处理"
		 */
		 	HANDLED((short) 2, "已处理"),
		/**
		 * (short) 3, "已忽略"
		 */
		 	IGNORE((short) 3, "已忽略");

	private short code;
	private String msg;

	private StatusEnumForExpose(short code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public short getCode() {
		return code;
	}

	public void setCode(short code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	@Override
	public String toString() {
		if (this != null) {
			Map<String, Object> allMap = new HashMap<String, Object>();
			allMap.put("code", this.code);
			allMap.put("msg", this.msg);
			String result = JSONObject.toJSONString(allMap);
			result = result.replaceAll("\"", "'");
			return result;
		}
		return super.toString();
	}
	
	public static StatusEnumForExpose getStatusEnumByCode(short code) {
		for (StatusEnumForExpose _enum : StatusEnumForExpose.values()) {
			if (_enum.getCode() == code) {
				return _enum;
			}
		}
		return null;
	}
}
